import cv2
import numpy as np

# 小demo实现认识色彩转换
o = cv2.imread('x.jpg')
hsv = cv2.cvtColor(o,cv2.COLOR_BGR2HSV)
min_HSV = np.array([0,10,80],dtype=np.uint8)
max_HSV = np.array([33,255,255],dtype=np.uint8)

# cv2.inRange()用于判断像素内像素点是否在指定的范围值
mask = cv2.inRange(hsv,min_HSV,max_HSV)
# 按位与截取脸部
result = cv2.bitwise_and(o,o,mask=mask)
cv2.imshow('img',o)
cv2.imshow('result',result)
cv2.waitKey()
cv2.destroyAllWindows()